package com.breeze.blockchain;

import com.mybatisflex.core.BaseMapper;
import java.net.InetAddress;
import java.net.UnknownHostException;
import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.core.env.Environment;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.web.socket.config.annotation.EnableWebSocket;

/**
 * 启动程序
 *
 * @author breeze
 */
@Slf4j
@EnableScheduling
@EnableAspectJAutoProxy(exposeProxy = true)
@EnableAsync
@EnableWebSocket
@Configuration
@MapperScan(
    value = {"com.breeze.blockchain.**.mapper"},
    markerInterface = BaseMapper.class)
@SpringBootApplication(scanBasePackages = {"com.breeze.blockchain", "com.breeze.components.oss"})
public class BlockchainDemoApplication {

  public static void main(String[] args) throws UnknownHostException {
    ConfigurableApplicationContext application =
        SpringApplication.run(BlockchainDemoApplication.class, args);
    Environment env = application.getEnvironment();
    String ip = InetAddress.getLocalHost().getHostAddress();
    String port = env.getProperty("server.port", "8080");
    log.info(
        """
        \n----------------------------------------------------------
        \tApplication is running! Access URLs:
        \tLocal: \t\thttp://localhost:{}/swagger-ui.html
        \tExternal: \thttp://{}:{}/swagger-ui.html
        ----------------------------------------------------------
        """,
        port,
        ip,
        port);
  }
}
